From 0daab815d59e65401b3cbf5021fc710cd28acb08 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Fri, 30 Jan 2009 11:13:06 +0000 Subject: [PATCH] amd-iommu: obtain page_alloc_lock before traversing a domain's page list From all I can tell, this doesn't violate lock ordering as other places call heap allocation functions from inside hd->mapping_lock. Signed-off-by: Jan Beulich --- xen/drivers/passthrough/amd/iommu_map.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/xen/drivers/passthrough/amd/iommu_map.c b/xen/drivers/passthrough/amd/iommu_map.c index 32d0389dbd..0009d72699 100644 --- a/xen/drivers/passthrough/amd/iommu_map.c +++ b/xen/drivers/passthrough/amd/iommu_map.c @@ -567,6 +567,8 @@ int amd_iommu_sync_p2m(struct domain *d) if ( hd->p2m_synchronized ) goto out; + spin_lock(&d->page_alloc_lock); + page_list_for_each ( page, &d->page_list ) { mfn = page_to_mfn(page); @@ -579,6 +581,7 @@ int amd_iommu_sync_p2m(struct domain *d) if ( iommu_l2e == 0 ) { + spin_unlock(&d->page_alloc_lock); amd_iov_error("Invalid IO pagetable entry gfn = %lx\n", gfn); spin_unlock_irqrestore(&hd->mapping_lock, flags); return -EFAULT; @@ -587,6 +590,8 @@ int amd_iommu_sync_p2m(struct domain *d) set_iommu_l1e_present(iommu_l2e, gfn, (u64)mfn << PAGE_SHIFT, iw, ir); } + spin_unlock(&d->page_alloc_lock); + hd->p2m_synchronized = 1; out: -- 2.30.2